package com.tiancheng.trade.payment.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tiancheng.trade.payment.mapper.QrFlowTradeMapper;
import com.tiancheng.trade.payment.model.QrFlowTrade;
import com.tiancheng.trade.payment.service.QrFlowTradeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: likailun
 * @Description: 二维码支付交易记录-service impl
 * @Date: create in 2021/9/13 5:35 下午
 */
@Service
@Slf4j
public class QrFlowTradeServiceImpl implements QrFlowTradeService {
    @Resource
    private QrFlowTradeMapper qrFlowTradeMapper;

    @Override
    public void save(QrFlowTrade qrFlowTrade) {
        qrFlowTradeMapper.insert(qrFlowTrade);
    }

    @Override
    public List<QrFlowTrade> findByFlowId(String flowId) {
        QueryWrapper<QrFlowTrade> conditions = new QueryWrapper<>();
        conditions.eq("flow_id", flowId);
        conditions.orderByDesc("id");
        return this.qrFlowTradeMapper.selectList(conditions);
    }

    @Override
    public List<QrFlowTrade> findByOrderId(String orderId) {
        QueryWrapper<QrFlowTrade> conditions = new QueryWrapper<>();
        conditions.eq("order_id", orderId);
        conditions.orderByDesc("id");
        return this.qrFlowTradeMapper.selectList(conditions);
    }
}
